<template>
  <div>
    <el-header>
      <el-menu
        router
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
      >
        <img
          src="./img/logo.png"
          alt=""
          class="logoImag"
          @click="$router.push('/article-list')"
        >
        <el-submenu
          index="2"
          class="pcNav"
        >
          <template slot="title">
            <i class="el-icon-user-solid"> 管理员 </i>
          </template>
          <el-menu-item index="/login">登录</el-menu-item>
        </el-submenu>
        <el-menu-item
          index="/about"
          class="pcNav"
        >关于博客</el-menu-item>
        <el-menu-item
          index="/article-list"
          class="pcNav"
        >首页</el-menu-item>

        <el-submenu
          index="/article-list"
          class="phoneNav"
        >
          <template slot="title">
            <i class="el-icon-s-fold"> </i>
          </template>
          <el-menu-item index="/article-list">首页</el-menu-item>
          <el-menu-item index="/about">关于博客</el-menu-item>
          <el-menu-item index="/login">管理员登录</el-menu-item>

        </el-submenu>
        <el-menu-item>
          <el-popover
            placement="bottom"
            title=""
            width="200"
            trigger="click"
            content=""
          >
            <el-form
              :inline="true"
              :model="formInline"
              class="demo-form-inline"
            >
              <el-form-item>
                <el-input
                  v-model="searchContent"
                  placeholder="请搜索"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  type="primary"
                  @click="onSubmit"
                >查询</el-button>
              </el-form-item>
            </el-form>
            <el-button slot="reference"><i class="el-icon-search"></i></el-button>
          </el-popover>
        </el-menu-item>
      </el-menu>

    </el-header>
    <el-container class="container">
      <el-container>
        <el-main>
          <keep-alive exclude="article-detail">
            <router-view></router-view>
          </keep-alive>
        </el-main>
        <el-aside width="200px">
          <el-card>
            <h3 class='aside-nav'> &nbsp;&nbsp; 分类</h3>
            <el-divider></el-divider>
            <div class="aside-content">
              <el-tag
                v-for="label in labels"
                :key="label"
                @click="$router.push('/result-article/'+label.label)"
              >{{label.label}}</el-tag>
            </div>
          </el-card>
          <el-card>
            <h3 class='aside-nav'> &nbsp;&nbsp; 最新留言</h3>
            <el-divider></el-divider>
            <div
              class="comment-item"
              v-for="comment in comments"
              :key="comment"
              @click="$router.push('/article/'+comment.article_id)"
            >
              <div
                class="comment-content"
                v-html="comment.content"
              ></div>
              <div class="comment-info">
                <div class="comment-name">
                  <i class="el-icon-user-solid"></i>{{comment.visitor_name}}
                </div>
                <div class="comment-date">{{comment.create_at}}</div>
              </div>
            </div>
          </el-card>
          <el-card>
            <h3 class='aside-nav'> &nbsp;&nbsp; 友情链接</h3>
            <el-divider></el-divider>
            <ul class="share-link">
              <li> <a href="https://element.eleme.cn/#/zh-CN/component/icon">饿了么组件</a>
              </li>
              <li> <a href="https://cn.vuejs.org/">vue的中文文档</a>
              </li>
              <li> <a href="https://uniapp.dcloud.io/">uniapp开发文档</a>
              </li>
              <li> <a href="https://developers.weixin.qq.com/community/homepage">小程序开发者社区</a>
              </li>
              <li> <a href="https://vant-contrib.gitee.io/vant/">vant组件文档</a>
              </li>
              <li> <a href="https://www.tjcblog.com/">谭先生的个人博客</a>
              </li>
              <li> <a href="https://v3.bootcss.com/">bootstrap</a>
              </li>
              <li> <a href="https://www.nowcoder.com/">牛客网</a>
              </li>
              <li> <a href="https://www.csdn.net/ ">csdn官方网站</a>
              </li>
            </ul>
          </el-card>
        </el-aside>
      </el-container>
    </el-container>
    <div class="footer">Copyright2018-2021张信凯个人博客版权所有. 基于flask-vue搭建.</div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      searchContent: '',
      comments: [],
      labels: []
    }
  },
  created () {
    this.getcomment()
    this.getlabel()
  },
  methods: {

    async getcomment () {
      const res = await this.$http.get('/article/getcomment')
      this.comments = res.data.data
      console.log(res)
    },
    async getlabel () {
      const res = await this.$http.get('/article/getlabel')
      this.labels = res.data.data
      console.log(res)
    },
    onSubmit () {
    }
  }

}
</script>
<style lang="less" scoped>
.footer {
  text-align: center;
  margin: 20px 0;
}
.comment-item {
  margin-bottom: 15px;
  .comment-content {
    margin-bottom: 10px;
  }
  .comment-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #999999;
    font-size: 12px;
    .comment-name {
    }

    .comment-date {
    }
  }
}
ul {
  li {
    height: 25px;
    line-height: 25px;
  }
  li a:hover {
    color: #409eff;
  }
  a::before {
    content: "";
    display: inline-block;
    height: 5px;
    width: 5px;
    background-color: #409eff;
    border-radius: 5px;
  }
}
.el-menu-item .el-button {
  margin-bottom: 10px;
}
.logoImag {
  position: absolute;
  left: 0;
  height: 61px;
}
.el-divider {
  margin: 10px 0px;
}

.aside-nav {
  height: 20px;
  line-height: 20px;
  text-align: left;
}
.aside-nav::before {
  content: "";
  position: absolute;
  width: 6px;
  height: 22px;

  background-color: #409eff;
}
.el-tag {
  margin: 5px;
  float: left;
}
.phoneNav {
  display: none;
}
.el-card {
  width: 95%;
  margin: 15px 0;
  height: 300px;
}
.el-menu--horizontal > .el-menu-item {
  font-size: 20px;
  float: right;
}
/deep/.el-submenu__title {
  font-size: 20px !important;
}
.el-menu--horizontal > .el-submenu {
  float: right;
  margin-right: 200px;
}
.label {
  margin: 5px;
}
.el-header,
.el-footer {
  padding: 0;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-header {
  top: 0px;
}

.el-aside {
  color: #333;
  width: 25% !important;
}

.el-main {
  color: #333;
  text-align: start;
  line-height: 20px;
  flex: 0.9;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  box-sizing: border-box;
}

.el-menu--horizontal > .el-menu-item.is-active {
  border-bottom: 2px solid #fff;
  color: #303133;
}

@media screen and (min-width: 1280px) {
  .container {
    width: 1220px;
  }
}

@media screen and (max-width: 1280px) {
  .container {
    width: 930px;
    /deep/.read-num {
      display: none;
    }
    /deep/.date {
      display: none;
    }
  }
}

@media screen and (max-width: 991px) {
  .container {
    width: 740px;
    .el-menu--horizontal > .el-submenu {
      float: right;
      margin-right: 0px;
    }
    .el-aside,
    .pcNav {
      display: none;
    }
    .el-main {
      margin: 0 auto;
    }
    .phoneNav {
      display: block;
    }
  }
}

@media screen and (max-width: 740px) {
  .el-container {
    width: 100%;
    .el-main {
      width: 100%;
    }
  }
}
</style>
